#! /bin/bash
export LANG=zh_CN.UTF-8
HIVE_HOME=/usr/bin/hive


${HIVE_HOME} -S -e "
--分区
SET hive.exec.dynamic.partition=true;
SET hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode=10000;
set hive.exec.max.dynamic.partitions=100000;
set hive.exec.max.created.files=150000;
insert into edu_dwb.dwb_customer_detail
select
r.id,
r.create_date_time,
r.deleted,
r.customer_id,
r.origin_type,
r.itcast_clazz_id,
r.itcast_school_id,
r.itcast_subject_id,
r.origin_channel,
r.creator,
r.payment_state,
r.payment_time,
--来自customer_clue表的字段,
c.id as clue_id,
--来自customer_appeal表的字段,
a.appeal_status,
--来自itcast_clazz的id,
z.itcast_school_name,
z.itcast_subject_name,
--来自employee表的字段,
e.tdepart_id,
--来自scrm_department表
d.name
from edu_dwd.sq_ft_customer_relationship r
left join edu_dwd.sq_dim_employee e on r.creator =e.id
left join edu_dwd.sq_dim_itcast_clazz z on r.itcast_clazz_id=z.id
left join edu_dwd.sq_dim_scrm_department d on e.tdepart_id=d.id
left join edu_dwd.sq_ft_customer_clue c on r.id= c.customer_relationship_id
left join edu_dwd.sq_dim_customer_appeal a on c.customer_relationship_id=a.customer_relationship_first_id"